home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Complete Applications / 4D Programming / External Procedures / Uppercase / UpperCaseFirst note.text next >
Encoding:
Text File  |  1987-09-22  |  1.6 KB  |  72 lines  |  [TEXT/ttxt]

  1. san luis revisited
  2.  
  3. (or... San Luis Revisited, the Milwaukee Solution)
  4.  
  5. Ross Henderson uploaded one way to solve the problem of ensuring that each word in a
  6. string begins with an upper case character.  Here is another using an external procedure that is
  7. much faster since you are not dependant on 4D's interpreter.
  8.  
  9. I wrote the enclosed external procedure for an application I am writing.  Forthose of you who are
  10. interested, the code (LightSpeed C™) is below.  Check out Acius's Tech Note #8 if you are using
  11. LIghtSpeed, because producing externals has a few peculiar twists you will need to know about.
  12.  
  13. To call the procedure (after it is intalled) just do something like this:
  14.  
  15.     UpperCaseFirst(vMyString)
  16.  
  17. Pretty easy, huh?
  18.  
  19.  
  20.  
  21.  
  22. Note:  I am pretty sure that you may not pass a string field this way.  You would need to put the
  23. contents of the field into the variable, pass the variable to UpperCaseFirst, and return the
  24. variable to the field.  eg.
  25.  
  26. vMyString := [MyFile]MyField
  27. UpperCaseFirst(vMyString)
  28. [MyFile]MyField := vMyString
  29.  
  30.  
  31. Like the man said,  I use the external, It works for me.  If if freaks out on you, well...
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. /*     UpperCaseFirst.c
  42.  *    
  43.  *    Gregory James
  44.  *    Tekton Software, Inc.
  45.  *    MCI: TEKTON
  46.  *    CIS: 75106,1773
  47.  *    (414) 962-0334
  48. */
  49.  
  50. #include <stdio.h>
  51.  
  52. pascal main(theString)
  53. char    *theString;
  54. {
  55.     short    i;
  56.     char    *myPtr;
  57.     PtoC(theString);
  58.     for(i=0;i<strlen(theString);i++){
  59.         if(theString[i]>64 && theString[i]<91) theString[i] += 32;
  60.     }
  61.     myPtr=theString;
  62.     if(*myPtr>96 && *myPtr<123) *myPtr -= 32;
  63.     myPtr++;
  64.     while(*myPtr!='\0'){
  65.         if(*myPtr == ' '){
  66.             if(*(myPtr+1)>96 && *(myPtr+1)<123) *(myPtr+1) -= 32;
  67.         }
  68.         myPtr++;
  69.     }
  70.     CtoP(theString);
  71. }
  72.